Самые интересные фичи Python 3.12, которые уже можно тестить и встраивать в проекты
1️⃣ Улучшенный match-case
Теперь можно использовать «захват» значений прямо в паттернах:
def http_status(code): match code: case 200 | 201 | 202 as ok: return f"Success: {ok}" case 400 as bad | 404 as bad: return f"Client error: {bad}" case _: return "Other"
Большая гибкость и меньше «шаблонных» переменных!
2️⃣ Новый оператор f”{…=}" для отладки
Позволяет вывести и имя, и значение переменной в одной строке:
user = "Alice" age = 29 print(f"{user=}, {age=}") # Выведет: user='Alice', age=29
Больше никаких лишних print("user", user)!
3️⃣ Оптимизация работы с памятью и скорость
Команда CPython продолжает ускорение интерпретатора:
* Выделение объектов стало быстрее * Сборщик мусора реже «паузит» приложение
Это особенно заметно в тяжёлых сервисах и бэкендах.
4️⃣ Новые API для типов
Добавили typing.Self и более гибкие Generic-типизации:
from typing import Self
class Builder: def set_name(self, name: str) -> Self: self.name = name return self
b = Builder().set_name("Demo")
Удобнее писать цепочки вызовов без «# type: ignore»!
💡Что попробовать прямо сейчас?
1. Установить Python 3.12 pre-release:
pyenv install 3.12.0b4
2. Переписать пару функций с match-case. 3. Пощупать f"{var=}" в дебаге.
Самые интересные фичи Python 3.12, которые уже можно тестить и встраивать в проекты
1️⃣ Улучшенный match-case
Теперь можно использовать «захват» значений прямо в паттернах:
def http_status(code): match code: case 200 | 201 | 202 as ok: return f"Success: {ok}" case 400 as bad | 404 as bad: return f"Client error: {bad}" case _: return "Other"
Большая гибкость и меньше «шаблонных» переменных!
2️⃣ Новый оператор f”{…=}" для отладки
Позволяет вывести и имя, и значение переменной в одной строке:
user = "Alice" age = 29 print(f"{user=}, {age=}") # Выведет: user='Alice', age=29
Больше никаких лишних print("user", user)!
3️⃣ Оптимизация работы с памятью и скорость
Команда CPython продолжает ускорение интерпретатора:
* Выделение объектов стало быстрее * Сборщик мусора реже «паузит» приложение
Это особенно заметно в тяжёлых сервисах и бэкендах.
4️⃣ Новые API для типов
Добавили typing.Self и более гибкие Generic-типизации:
from typing import Self
class Builder: def set_name(self, name: str) -> Self: self.name = name return self
b = Builder().set_name("Demo")
Удобнее писать цепочки вызовов без «# type: ignore»!
💡Что попробовать прямо сейчас?
1. Установить Python 3.12 pre-release:
pyenv install 3.12.0b4
2. Переписать пару функций с match-case. 3. Пощупать f"{var=}" в дебаге.
Bitcoin is built on a distributed digital record called a blockchain. As the name implies, blockchain is a linked body of data, made up of units called blocks that contain information about each and every transaction, including date and time, total value, buyer and seller, and a unique identifying code for each exchange. Entries are strung together in chronological order, creating a digital chain of blocks. “Once a block is added to the blockchain, it becomes accessible to anyone who wishes to view it, acting as a public ledger of cryptocurrency transactions,” says Stacey Harris, consultant for Pelicoin, a network of cryptocurrency ATMs. Blockchain is decentralized, which means it’s not controlled by any one organization. “It’s like a Google Doc that anyone can work on,” says Buchi Okoro, CEO and co-founder of African cryptocurrency exchange Quidax. “Nobody owns it, but anyone who has a link can contribute to it. And as different people update it, your copy also gets updated.”
What is Telegram?
Telegram is a cloud-based instant messaging service that has been making rounds as a popular option for those who wish to keep their messages secure. Telegram boasts a collection of different features, but it’s best known for its ability to secure messages and media by encrypting them during transit; this prevents third-parties from snooping on messages easily. Let’s take a look at what Telegram can do and why you might want to use it.
Библиотека Python разработчика | Книги по питону from vn